import { useState } from 'react';

function ConditionalRender() {
  const [loggedIn, setLoggedIn] = useState(false);

  return (
    <div>
      {loggedIn ? <p>欢迎回来！</p> : <p>请先登录。</p>}
      <button onClick={() => setLoggedIn(!loggedIn)}>
        {loggedIn ? '退出登录' : '登录'}
      </button>
    </div>
  );
}

export default ConditionalRender;
